#include "httphelper.h"

namespace cores
{
    namespace common
    {
        HttpHelper * HttpHelper::globalInstance = nullptr;

        HttpHelper::HttpHelper() 
        {
            if (HttpHelper::globalInstance == nullptr)
            {
                HttpHelper::globalInstance = this;
            }
        }

        HttpHelper::~HttpHelper()
        {
            if (HttpHelper::globalInstance == this)
            {
                HttpHelper::globalInstance = nullptr;
            }
        }

        void HttpHelper::SendWarmRequest(const string & code)
        {
            if (HttpHelper::globalInstance == nullptr)
                return;

            HttpHelper::globalInstance->sendWarmRequest(code);
        }

        string HttpHelper::GetConfigFromApi(const string& stationCode)
        {
            if (HttpHelper::globalInstance == nullptr)
                return string();

            return HttpHelper::globalInstance->getConfigFromApi(stationCode);
        }

        bool HttpHelper::CompareFileVersion()
        {
            if (HttpHelper::globalInstance == nullptr)
                return true;

            return HttpHelper::globalInstance->compareFileVersion();
        }

        void HttpHelper::DownloadFile()
        {
            if (HttpHelper::globalInstance == nullptr)
                return;

            HttpHelper::globalInstance->downloadFile();
        }
    }
}